<?php
require_once 'includes/class.phpmailer.php';
session_start();


$proId=$_REQUEST['SellProduct'];



$userId 		= $_SESSION['user_id_sess'];	
$itemId			= $_REQUEST['SellProduct'];


$sqlSelProd		= "SELECT * FROM tbl_product WHERE product_id='$proId'";
$rstSelProd		= mysql_query($sqlSelProd) or die(mysql_error());
$rowSelProd		= mysql_fetch_array($rstSelProd);
$productOwner		= $rowSelProd['posted_by'];

$productName		= $rowSelProd['product_name'];
$pro_condition		= $rowSelProd['pro_condition'];
$localPickup		= $rowSelProd['localPickup'];
$quantity		= $rowSelProd['quantity'];
$postedDate		= $rowSelProd['posted_date'];
$posted_by		= $rowSelProd['posted_by'];
$bargainDate 		= $rowSelProd['bargain_duration'];
$sellingType		= $rowSelProd['selling_type'];
$shipping		= $rowSelProd['shipping'];
$product_description	= $rowSelProd['product_description'];
$gift_name		= $rowSelProd['gift_name'];
$gift_description	= $rowSelProd['gift_decsription'];
$gift_image		= $rowSelProd['gift_image'];
$return_id		= $rowSelProd['return_id'];
$remarks		= $rowSelProd['remarks'];
$commission		= $rowSelProd['commission'];
$productPrice		= $rowSelProd['product_price'];
$bargainAmount		= $rowSelProd['bargain_amount'];
$bargain_commission_option = $rowSelProd['bargain_commission_option'];

$sqlSelItem = "SELECT item_id FROM tbl_items WHERE product_id='$proId' 
			   AND seller_id='$userId' AND owner_id='$productOwner'";
$rstSelItem		= mysql_query($sqlSelItem);
$rowSelItem		= mysql_fetch_array($rstSelItem);
//$proId			= $rowSelItem['product_id'];	
//echo $productOwner		= $rowSelItem['seller_id'];
$productDesc		= $rowSelItem['product_description'];
$productCategory	= $rowSelItem['category_id'];




$gift 			= 0;
if(!empty($gift_name))
{
	$gift = 1;
}

if($shipping!='Free')
	$shipping 	= "$".number_format($rowSelProd['shipping'],2);
else
	$shipping 	= "free shipping available";

$sales_tax 		= number_format($rowSelProd['sales_tax'],2);

$pimage 		= getProductImage($proId,'p');
 //echo $pthumb;
if($pimage['thumb']!="") {
	$productThumbnail	= $pimage['thumb'];
	$productMedium		= $pimage['image'];	
}
else {
	$productThumbnail	= "images/no_image.gif";
	$productMedium		= "images/no_image.gif";
} 
		  
$catInfo=getCategory($productCategory);

$ownerName 	= '';
$user_type1 	= '';
$adr = '';

$qry = mysql_query("select email,business_name,first_name,last_name,user_type,address_line_1,city,state,country,zip from tbl_users where user_id=$productOwner") or die(mysql_error());
$c_qry = mysql_num_rows($qry);
if($c_qry > 0)
{
	$users = mysql_fetch_array($qry);
	$ownerName 	= $users['first_name'];
	$email		= $users['email'];
	$user_type1 	= $users['user_type'];
	$address 	= $users['address_line_1'];
	$city		= $users['city'];
	$state		= $users['state'];
	$country	= $users['country'];
	$zip		= $users['zip'];
	$business_name	= $users['business_name'];
	$cou		= get_country_details($country);
	$country_name	= $cou['country_name'];
	$adr 		= $address.", ".$state.",".$country_name;
}

$sqlSelItem = "SELECT item_id FROM tbl_items WHERE product_id='$proId' AND seller_id='$userId' AND owner_id='$productOwner'";
$rstSelItem = mysql_query($sqlSelItem) or die(mysql_error());			   
$numSelItem = mysql_num_rows($rstSelItem);

$ss = mysql_query("select googleMapKey from tbl_settings where setting_id=1") or die(mysql_error());
 $tbl_settings = mysql_fetch_array($ss);
 if($tbl_settings) $googleMapKey = $tbl_settings['googleMapKey'];  else $googleMapKey='';
?>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;oe=utf-8&amp;key=<?php echo $googleMapKey; ?>" type="text/javascript"></script>



<style type="text/css">
	span#add-wishlist { color:#0000CC; padding:5px; font-size:12px; }	
</style>

<input type="hidden" id="address_of_seller<?php echo $proId;?>" value="<?php echo $adr; ?>" />
<input type="hidden" name="lat<?php echo $proId;?>" value="" id="lat<?php echo $proId;?>" />
<input type="hidden" name="lon<?php echo $proId;?>" value="" id="lon<?php echo $proId;?>" />
								
<script type="text/javascript">
$(document).ready(function() {

	var geocoder, location1, location2, gDir;
	geocoder = new GClientGeocoder();
	gDir = new GDirections();
	var address_of_seller = $('#address_of_seller<?php echo $proId;?>').val();
	//alert(address_of_seller);
	geocoder.getLocations(address_of_seller, function (response) {
	if (!response || response.Status.code != 200)
	{
		//alert("Sorry, we were unable to geocode the first address");
	}
	else
	{
		location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
		//alert(response.Placemark[0].Point.coordinates[1]);
		$('#lat<?php echo $proId;?>').val(response.Placemark[0].Point.coordinates[1]);
		$('#lon<?php echo $proId;?>').val(response.Placemark[0].Point.coordinates[0]);
	}
	});
});
</script>
<script language="javascript1.2">
function addtocart(id,name,amt,sh,q,tax)
{
	location.href="addtocart.php?id="+id +"&name="+name+"&amt="+amt+"&shipping="+sh+"&qty=1"+"&tax="+tax;
}
function addtocart_buy(id,name,amt,sh,q,tax)
{
	location.href="addtocart_buy.php?id="+id +"&name="+name+"&amt="+amt+"&shipping="+sh+"&qty=1"+"&tax="+tax;
}
function show_map(pid)
{
  // var pos = $('#more_info_link').position();
  var ntop = ( $(window).height() - $('#map_box').height() ) / 2+$(window).scrollTop();
  var nleft = ( $(window).width() - $('#map_box').width() ) / 2+$(window).scrollLeft();
  
  $('#map_box').css({'left': nleft, 'top':ntop});
  $('#map_box').show();
  var lat = $('#lat'+pid).val();
  var lon = $('#lon'+pid).val();
  //alert(lat+' '+lon);
  initialize(lat,lon);
 
  
}



function initialize(lat,lon) {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(lat, lon), 13);
    var latlng = new GLatLng(lat,lon);
    map.addOverlay(new GMarker(latlng));
    
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
  }
}
function sendMail()
{
	var proId = '<?php echo $proId?>';
	var url = "<?php echo $base_url;?>report_item.php";
	$.post(url,
	{ 'prodId':proId},
	function(data)
	{
		alert('Item successfully reported');
	},
	'html');
}
</script>

<script language="javascript" type="text/javascript">
function show_ask()
{
  var ntop = ( $(window).height() - $('#ask_popup').height() ) / 2+$(window).scrollTop();
  var nleft = ( $(window).width() - $('#ask_popup').width() ) / 2+$(window).scrollLeft();

  $('#ask_popup').css({'left': nleft, 'top':ntop});
  $('#ask_popup').fadeIn('slow');
}
</script>

<div style=" display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc; opacity:0.9;" class="user_popup" id="ask_popup">
  <span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#ask_popup').fadeOut('slow');">x</label></span>
  <span style="float:left; width:100%; margin-bottom:10px;" id="desc_info">Please send us the content of Ask Question.</span>
</div>

<table width="100%" border="0">

	<tr>
		<td>
			<div style="width: 950px; float: left; vertical-align: top; margin:15px 0px 5px 0px;">
		
				<div class="mypg_left_out">
					<a href="javascript:history.back();" style="text-decoration: none;"><img src="images/arrow_back.png" style="border:none;margin:0px 5px 0px 0px;" />Back to Search Results</a>
					<br /><br />
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" style="text-decoration: none;" onclick="sendMail()">Report Item</a>
				</div>
				
		
				<div class="fullbox_out">	
					<strong class="orangehead">Choose Products to Sell</strong>
					<p style="margin: 5px 0px;" class="grey_txt">
						<i>Sell products for business or people and earn a commission. You choose the item with the best price and commission.</i>
					</p>	
				</div>
			</div>
	   	</td>
	</tr>

	<tr>
		<td>
			<div class="fulldiv"><h2>Products</h2></div>
	
			<div class="fulldiv">
				<span id='listed-in'>Listed in: <a href='index.php?cat=<?php echo $catInfo['categoryId']; ?>'><?php echo $catInfo['categoryName']; ?></a> >> <a href='index.php?cat=<?php echo $catInfo['subcategoryId']; ?>'><?php echo $catInfo['subcategoryName']; ?></a></span>
				<br style="clear:both;" /><br />
	   
	   
				<?php
				if(!empty($_POST['hidBargain'])) {
					if($_SESSION['user_id_sess']!="") {
						//$askingAmount = $_POST['asking_price'];
						$offerAmount = $_POST['offer_price'];
						//$askingCommission = $_POST['asking_commission'];
						//$offerCommission = $_POST['offer_commission'];
						$comment = $_POST['bargain_comment'];
						$askingAmount 	= $productPrice;
						
						
						//if($offerCommission)
						//{
							//$commision="Commision: ".number_format($_POST['offer_commission'],2);
						//}
						
						//check user already selling this item or not
						if($numSelItem>0) {
							echo "<div id='err-msg'> Already you have a rights to sell this item... </div>";
						}
								
						else
						{
							if($_POST['hidBargain']=="add") {
								//asking_commission='$askingCommission', offer_commision='$offerCommission', 
							$sqlInsBargain="INSERT INTO tbl_bargain set 
											item_id='$proId',
											owner_id='$productOwner',
							 				asking_amount='$askingAmount', 
											user_id='$userId', 
											user_type='2', 
											bargain_type=2,
											offer_amount='$offerAmount', 		
											comment='$comment',
											status='offer'";
							$rstInsBargain=mysql_query($sqlInsBargain);	
							$add_rst=mysql_insert_id();
							if($add_rst)
							{ 
								$emailContent="You are receiving this message because (".$_SESSION['user_name'].") has made an offer towards (<a href=index.php?SellProduct=".$proId.">".$productName."</a>)<br><p>Offer: $".number_format($offerAmount,2)."<p><p>".$comment."</p>";
								mysql_query("insert into tbl_messages(senderid,recieverid,productid,subject,message,posteddate,status,type,itemid,section,bargain_id,ownerid) values('".$_SESSION['user_id_sess']."','".$productOwner."','".$proId."','Offer Recieved','".addslashes($emailContent)."','".date("Y-m-d")."','1','Bargain','".$itemId."','M','".$add_rst."','".$productOwner."')");
								$sqlSellers="select * from tbl_items where product_id='".$proId."'";
								$resSellers=mysql_query($sqlSellers);
								$parentid=mysql_insert_id();
								while($resSellers=mysql_fetch_array($resSellers))
								{
									if($_POST['recieverid']!=$resSellers['seller_id'])
									{
										if($_SESSION['rid']!=$resSellers['seller_id'])
										{
											$_SESSION['rid']=$resSellers['seller_id'];
											mysql_query("insert into tbl_messages(senderid,recieverid,productid,subject,message,posteddate,status,type,itemid,section) values('".$_SESSION['user_id_sess']."','".$resSellers['seller_id']."','".$proId."','Offer Recieved','".addslashes($emailContent)."','".date("Y-m-d")."','1','Bargain','".$itemId."','M')");
										}
									}
								}
								$mailmsg="<table width='100%' border='0' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12px; line-height:25px'>
								<tr><td height='32' colspan='2' style='font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;'>".$emailContent."</td></tr></table>";
								
								$mail = new PHPMailer(); // defaults to using php "mail()"
								$mail->MsgHTML($mailmsg);
								$mail->From       = "mail@swapen.com";
								$mail->FromName   = "Swapen.com";
								$mail->Subject    = "Offer Recieved";
								$mail->AddAddress($email);
								$mail->Send();
									
								echo "<div id='suc-msg'>Bargain placed successfully.</div>"; }
								else
								{
									echo "<div id='err-msg'>Error on placing your bargain.</div>";
								}						
							}						
						}
					}
					else
					{
						echo "<script type='text/javascript'> window.location='index.php?signin&url=bargain'; </script>";
					}					
				}
				
				?>
	   
	  
				<form name="frmProductInfo" id="frmProductInfo" method="post">
					<input type="hidden" name="hidBargain" id="hidBargain">
	   
					<div class="desc_div">
						<div class="descbox">
							<table width='100%' border='0' align='center' cellspacing='0'>
								<tr>
									<td>
										<div class="fulldiv">
										      <div style="width:300px; float:left;">
												<img src="<?php echo $productMedium; ?>" />				 
										      </div>
										      <div style="width:150px; float:left;">			 
												<img src="<?php echo $productThumbnail; ?>" />
												<div class="fulldiv">
													<a href="javascript:void(0);" onclick="openWindow('item_viewer.php?prod=<?php echo $proId; ?>&type=i','580','650');"><?php if(getImageCount($proId)!=0) echo getImageCount($proId)." images"  ?></a>
												</div>
										      </div>
										</div>
									</td>
								</tr>
			
								<tr>
									<td>
										<div class="fulldiv">
															
											<div class="greytab_out" style="float:left; margin:15px 5px -8px 25px;">
												<div class="greytab_left">&nbsp;</div>
												<div class="greytab_repeat" style="padding:5px;">
													Add to Store<img src="images/cart_ico.png" style="margin:0px 0px -3px 10px;" width="20px;" />
												</div>
												<div class="greytab_right">&nbsp;</div>
											</div>
						
											<div class="ads_out" style="margin:0px 0px 0px 10px;">
												<div class="ads_top"></div>
												<div class="ads_repeat">
														
													
													<div class="fulldiv" style="margin:5px 0px 5px 0px;">
														<div style="width:100px; float:left; margin:0px 5px 0px 10px;"><strong>Price </strong> </div>
														<div style="width:280px; float:left; margin:0px 10px 0px 0px;"><font style="color:#C43131; font-size:13px; font-weight:bold;">$<?php echo number_format($productPrice,2); ?> + </font><?php echo $shipping ?></div> 
													</div>
													
													
													<div class="fulldiv" style="margin:5px 0px 5px 0px;">	
														<div style="width:100px; float:left; margin:0px 5px 0px 10px; color:#3C3CBC;"><strong>Bargain</strong></div>
														<div style="width:280px; float:left; margin:0px 10px 0px 0px;">
															commission-$<?php echo number_format($commission,2);?>
															<div style="width:60px; float:right;">
															
																<a class="yellow_btn" href="javascript:void(0)" style="height: 22px; margin: 0px 10px 0; padding: 7px 5px 0;" onClick="funAddItem('<?php echo $proId; ?>','<?php echo $_SESSION['user_id_sess']; ?>','divAddItemToSeller','30');">ADD</a><br />
																<?php if($_SESSION['user_id_sess']) {?><a href="javascript:void(0)" onclick="window.open('sendowner_message.php?ownerid=<?php echo $productOwner;?>&productid=<?php echo $_GET['SellProduct'];?>','welcome','width=500,height=300')">Message</a><?php } else {?><a href="index.php?signin">Message</a><?php }?>
																
															</div>
															<span id="divAddItemToSeller" style="float:left; width:95%; text-align:right; color:green; font-weight:bold;"></span>
														</div>
														
													</div>
													<?php
													if($bargain_commission_option==1) {
													?>	
														<form name="frmProductInfo" id="frmProductInfo" method="post">
															<div class="fulldiv" style="margin:5px 0px 5px 0px;">	
																<div style="width:100px; float:left; margin:0px 5px 0px 10px;"><strong>Your Offer</strong></div>
																<div style="width:280px; float:left; margin:0px 10px 0px 0px;">
																<input type="text" class="inputbg" style="width:80px;" name="offer_price" id="offer_price" />								
																</div>
															</div>
										
															<div class="fulldiv" style="margin:5px 0px 5px 0px;">	
																<div style="width:100px; float:left; margin:0px 5px 0px 10px;"><strong>Add Comment</strong></div>
																<div style="width:280px; float:left; margin:0px 10px 0px 0px;">
																<textarea cols="6" rows="3" style="width:250px;" class="inputbg" name="bargain_comment" id="bargain_comment"></textarea>								
																</div>
															</div>
															
															<div class="fulldiv" style="margin:5px 0px 5px 0px;">	
																<div style="width:100px; float:left; margin:0px 5px 0px 10px;">&nbsp;</div>
																<div style="width:280px; float:left; margin:0px 10px 0px 0px;">
																	<?php if($userId!=$productOwner) { ?>
																		<input class="refer_btn" type="button" <?php if($userId==$productOwner) { echo " disabled "; } ?> name="btnCommit" value="Make Offer" onclick="funBargainSeller()">
																	
																	<?php
																	}
																	?>
																</div>
															</div>
														</form>
													<?php
													}
													?>
												</div>
												<!--end : ads_repeat-->
												<div class="ads_bot"></div>
											</div>
											<!--end:ads_out-->
										</div>			
									</td>
								</tr>
			
								<?php /*
								<tr>
									<td> 
										<div class="fulldiv" style="margin:5px 0px 5px 0px;">
									      
											<div style="width:200px; float:left;"><?php  echo checkShippingDetails($sellingType); ?></div>
									      
											<div style="width:180px; float:left;"> 
			  
												<?php if($_SESSION['user_id_sess']=="") { $usr=0; } else { $usr=$_SESSION['user_id_sess'];} ?>
												<?php if($_SESSION['user_id_sess']!=$productOwner && $_SESSION['user_type_sess']!=1) { ?>
													<a href="javascript:void(0);" <?php if($_SESSION['user_type_sess']=="3") {?>onclick="funAddWholeList('<?php echo $itemId; ?>','<?php echo $_SESSION['user_id_sess']; ?>','add-wishlist');"<?php } else {?>onclick="funAddList('<?php echo $itemId; ?>','<?php echo $_SESSION['user_id_sess']; ?>','add-wishlist');" class="yellow_btn" style="height: 22px; margin: 0px 10px 0; padding: 7px 5px 0;"><?php }?>Add to wishlist</a>
												<?php } ?>
												<br /><br /><span id="add-wishlist"></span>
											</div>
										</div>
									</td>
								</tr>
								
								<tr>
									<td>
										<div class="fulldiv" style="margin:5px 0px 5px 0px;">
																		
											<?php
											$sqlList="SELECT * FROM tbl_items WHERE product_id='$proId'";
											$rstList=mysql_query($sqlList);
											$rowList=mysql_num_rows($rstList);
											if($rowList>1)
											{ ?> Price Range: <?php 
												$sqlRange="SELECT MIN(price) as min_price FROM tbl_items WHERE product_id='$proId'";
												$rstRange=mysql_query($sqlRange);
												$rowRange=mysql_fetch_array($rstRange);
												$minp=$rowRange['min_price'];
												$sqlRange="SELECT MAX(price) as max_price FROM tbl_items WHERE product_id='$proId'";
												$rstRange=mysql_query($sqlRange);
												$rowRange=mysql_fetch_array($rstRange);
												$maxp=$rowRange['max_price'];
												?>
												<a href="index.php?spid=<?php echo $proId;?>"><?php echo "$".number_format($minp,2)." - $".number_format($maxp,2);?></a><?php
											} ?>	
										</div>
									</td>
								</tr>
								      */ ?>
								<tr>
									<td>
										<div class="fulldiv" style="margin:5px 0px 5px 0px; height:50px;">
										     <a class="bluelink" href="#" style="text-decoration:none;">Refer a friend to buy this item and make extra commission <img src="images/chat.png" height="40px" width="40px" border="0" style="margin:0px 0px -20px 0px;" /></a>		
										</div>
									</td>
								</tr>
							</table>
						</div>
					</div>
					<!--desc_div-->
	   
	   
					<div class="desc_div" style="margin:0px 0px 0px 5px;">
					
						<div class="descbox">
					
							<table width="100%" border="0" align="center">
						 
							<tr>
								<td>
									<div class="fulldiv">
										<strong class="blue_big"><?php echo "$productName";?></strong>&nbsp;
										<font class="black_big">-&nbsp;<?php echo strtoupper($pro_condition);?></font>				
									</div>
			
									<div class="fulldiv">
										<div style="float:left; width:225px;">
											<p class="grey_txt pro_ptag">
												<i style="float:left;">shipping - <?php echo $shipping;?></i>
											</p>
											<p class="grey_txt pro_ptag">
												<i style="float:left; margin:0px 5px 0px 0px">
													Product Owner:
												</i>
												
												<i style="float:left; color:#000000;">
													<?php echo $ownerName; ?>&nbsp;
												</i>
												<?php
												//$img_t = 'm.png';
												if($user_type1==3)  $img_t = "m.png";  
												else if($user_type1==2) $img_t = "s.png";
												else if($user_type1==5) $img_t = "w.png";
												?>
										<img src="images/<?php echo $img_t;?>" style="float:left; margin:-7px 0px 0px 0px;" <?php if($user_type1==3) { ?>title="Verified Merchant" alt="Verified Merchant"<?php } ?> />
												
											</p>
											<p class="grey_txt pro_ptag">
												<i style="float:left;">
													Quantity:
												</i>
												<i style="float:right; color:#000000; float:left;">
													<?php echo $quantity;?>
												</i>
											</p>
										</div>
										
										<div style="float:right; width:225px; margin:0px 0px 0px 2px; float:left;">
											<p class="grey_txt pro_ptag">
												<i style="float:right;">
													local pick up - <?php if($localPickup==1) echo "available"; else echo "not available"; ?>
												</i>
											</p>
											<p class="grey_txt pro_ptag" style="text-align:right;">
												<font>
													feedback
												</font>
												<font style="color:#000000;">
													<?php
													$numTotalFeedback=mysql_num_rows(mysql_query("select * from tbl_feedback where product_id='".$proId."'"));
													$sum_of_positive=mysql_fetch_array(mysql_query("select SUM(points) as total_positive from tbl_feedback where product_id='".$proId."' and rate=1"));
                                                    $sum_of_negative=mysql_fetch_array(mysql_query("select SUM(points) as total_negative from tbl_feedback where product_id='".$proId."' and rate=3"));													                                                    $totalTransaction=mysql_num_rows(mysql_query("select * from tbl_feedback where product_id='".$proId."' and rate!=2"));
													$feedback_rate=($sum_of_positive['total_positive']+$sum_of_negative['total_negative'])/$totalTransaction;
													if($numTotalFeedback>0 && $totalTransaction>0)
													{
													echo number_format($feedback_rate,2).'%'. " (".$numTotalFeedback.")";
													}
													else if($numTotalFeedback==0 && $totalTransaction==0)
													{
													echo '100%'. " (0)";
													}
													else
													{
													echo '100%'. " (1)";
													}
													?>
												</font>
											</p>
											<p class="pro_ptag">
												<font style="float:right;">
													<a href="seller_store.php?sid=<?php echo $productOwner;?>" class="bluelink">owner's store</a>
												</font>
											</p>
										</div>	
					
					
									</div>
									
									<div class="fulldiv">
									
										<div class="greytab_out" style="float:left; margin:15px 5px -8px 25px;">
											<div class="greytab_left">&nbsp;</div>
											<div class="greytab_repeat">
												Description
											</div>
											<div class="greytab_right">&nbsp;</div>
										</div>
										
										<div class="ads_out" style="margin:0px 0px 0px 10px;">
											<div class="ads_top"></div>
											<div class="ads_repeat" style="padding:0px 15px 0px 15px; width:404px;">
																		
												<?php
												$length = strlen($product_description);
												if($length > 90)
												{
													$product_description=wordwrap($product_description, 90, "<br />", true);
												}
												echo $product_description;
												?>					
											</div>
											<div class="ads_bot"></div>
										</div>
					
										<?php
										if($gift==1)
										{
										?>
										<div class="ads_out" style="margin:10px 0px 0px 10px;">
											<div class="ads_top"></div>
											<div class="ads_repeat" style="padding:0px 15px 0px 15px; width:404px;">
												
												<div class="protag_left">
																		
												<p class="pro_ptag grey_big">
												OWNER PROVIDING FREE GIFT</p>
												
												<p class="pro_ptag redtxt">
												<?php echo $gift_name?></p>
					
												<p class="pro_ptag black_big2">
												<?php echo $gift_description?></p>
												
												</div>
												
												<div class="protag_right">
													<?php
													if($gift_image!='')
													{
														$temp 	= explode('.',$gift_image);
														$temp1 	= explode('/',$temp[0]);
														$img 	= $temp1[2]."_thumb.".$temp[1];
													}
													?>
													<img src="products/thumb/<?php echo $img;?>" />
												</div>
																	
											</div>
											<div class="ads_bot"></div>
										</div>
										<?php
										}
										?>
									</div>
					
									<div class="fulldiv" style="margin:10px 0px 0px 0px;">
					
										<div style="float:left; width:285px;">
											<p class="grey_big pro_ptag">	
												Contact
											</p>
											<p class="grey_txt pro_ptag">
												<i style="float:left;">
													Product Owner:&nbsp;
												</i>
												<i style="float:left; color:#000000;">
													<?php echo $ownerName; ?>&nbsp;
												</i>
											</p>
											<p class="grey_txt pro_ptag">
												<i style="float:left;">
													item location:&nbsp; 
												</i>
												<?php
												
												if($user_type1==3)
												{
													
													
													$store_addr = $business_name.",<br />".$address.", ".$city."<br />".$state.", ".$country_name; 
												}
												else
												{
													$store_addr = $city.", ".$state; 
												}
												?>
												<i style="float:left; color:#000000; float:left;">
													<?php echo $store_addr; ?>
													<font style="color:#000000;">(<a href="javascript:void(0)" class="bluelink" onclick="show_map(<?php echo $proId; ?>)">map it</a>)</font>
												</i>
											</p>
											<p class="grey_big pro_ptag">
													Return Policy
											</p>
											<p class="grey_txt pro_ptag">
												<i style="float:left;">
													<?php echo $return_id.", ".$remarks; ?>
												</i>
											</p>
										</div>	
											
										<div style="float:right; width:155px; margin:0px 0px 0px 2px; float:left;">
											<p class="pro_ptag"  style="text-align:right;">
												<a href="javascript:void(0)" class="bluelink" onclick="show_ask()" id="ask_questions">Ask Question</a>
												<a class="refer_btn" href="#" style="height: 22px; margin: 10px 0 5px; 
												padding: 7px 5px 7px 5px; text-decoration: none;">Chat</a>
											</p>							
										</div>
									</div>
								</td>
							</tr> 
		             
							</table>
						</div>
						<!--descbox-->
					</div>
					<!--desc_div-->	
	   
					<?php
					/*
					<div class="desc_div"> 			
						<table width="100%" border="0" align="center">
					       
							<tr>
								
								<td width="53%" valign="top">
									<table  border="0" align="center" width="100%">              
										<tr>
											<td width="93%" height="28" colspan="2" class="uline">
			
												<?php
												
												echo "seller_id".$rowSelItem['seller_id']."<br>";
													echo $userId;
												if($rowSelItem['seller_id'] != $userId)
												{
													
												 ?>
												<table align="center" width="90%" border="0">
													<tr>
														<td height="33" align="center">
															<!--<input type="text" size="7" name="buy_amount">-->
															<input type="button" value="Buy" name="btnBuy" onclick="return addtocart_buy('<?php echo $itemId;?>','<?php echo $productName;?>','<?php echo $productPrice;?>','<?php echo $shipping;?>',1,'<?php echo $sales_tax;?>');">									
														</td>
													</tr>
													<tr>
														<td height="32" align="center"><input type="button" value="Add to Cart" onclick="return addtocart('<?php echo $itemId;?>','<?php echo $productName;?>','<?php echo $productPrice;?>','<?php echo $shipping;?>',1,'<?php echo $sales_tax;?>');"></td>
													</tr>
													<tr>
														<td height="27" align="center"><strong>Bargain</strong></td>
													</tr>
						
													<tr>
														<td align="center">
															<table width="84%"  border="0">
																<tr>
																	<td width="50%" align="center">Asking price </td>
																	<td width="50%" align="center">Your offer </td>
																</tr>
																<tr>
																	<td height="38" align="center"><input type="text" readonly size="7" id="asking_price" name="asking_price" value="<?php echo $bargainAmount; ?>"></td>
																	<td align="center"><input type="text" size="7"  name="offer_price" id="offer_price"></td>
																</tr>
																<tr>
																	<td colspan="2" align="center">Include Comment</td>
																</tr>
																<tr>
																	<td colspan="2" align="center">
																		<textarea name="bargain_comment" id="bargain_comment" style="height:150px; width:250px; "></textarea>
																		<input type="hidden" name="recieverid" value="<?php echo $productOwner;?>"/>
																		<input type="hidden" name="productOOwner" value="<?php echo $productOOwner;?>"/>
																		<input type="hidden" name="pname" value="<?php echo $productName;?>"/>
																	</td>
																</tr>
																<tr>
																	<td colspan="2" align="center"><input type="button" <?php if($userId==$productOwner) { echo " disabled "; } ?> name="btnCommit" value="Commit" onClick="funBargain();"></td>
																</tr>
															</table>
														</td>
													</tr>
												</table>
											<?php 	} ?>
											</td>
										</tr>
									</table>
								</td>
							</tr>          
						</table>
					</div>
					*/
					?>
				</form>
				<br /> 
			</div>
			<!--end:full_div-->
			
			<?php
			/*
			<div class="desc_div"> 
				<table width="100%" align="center" border="0">
					<tr>
						<td><strong>Questions and Offers</strong></td>
					</tr>
					<tr>
						<td>
							<?php 
							if(!empty($_POST['hidSellerReply']))
							{ 
								$parentBargain = $_POST['hidSellerReply'];
								if($_POST['hidType']=="add") {								
									$key = $_POST['hidReplyFor'];								
									$askAmt = $_POST['ask_amount'];
									$buyAmt = $_POST['buyer_amount'];
									$selCmt = $_POST['seller_comment'];
									if($askAmt[$key]=="") {
										echo "<div id='err-msg'>Enter asking amount.</div>";
									}
									
									else {
										$sqlAddReply="INSERT INTO tbl_bargain set product_id='$proId',
											asking_amount='$askAmt[$key]', 
											user_id='$userId', 
											parent_id='$parentBargain', 
											user_type='1', 
											offer_amount='$buyAmt[$key]', 
											bargain_type=1,
											comment='$selCmt[$key]', 
											status='reply'";
										$rstAddReply=mysql_query($sqlAddReply);		
										$addReply=mysql_insert_id();								
										if($addReply) { echo "<div id='suc-msg'>Your reply posted successfully.</div>"; }
										else { echo "<div id='err-msg'>Error on placing your reply.</div>"; }		
									}
								}
								elseif($_POST['hidType']=="delete") {
									$sqlDelReply="DELETE FROM tbl_bargain where bargain_id='".$_POST['hidSellerReply']."'";
									$rstDelReply=mysql_query($sqlDelReply);									
									if($rstDelReply) { echo "<div id='suc-msg'>Your reply deleted.</div>"; }
									else { echo "<div id='err-msg'>Error on deleting your reply.</div>"; }
								}	 
							}
							?>
							<form name="frmProductOffer" action="" method="post" id="frmProductOffer">
								<input type="hidden" name="hidSellerReply" id="hidSellerReply">
								<input type="hidden" name="hidReplyFor" id="hidReplyFor">
								<input type="hidden" name="hidType" id="hidType">
								<?php
								include_once("product_offer.php");
								?>
							</form>
						</td>
					</tr>
				</table>
			</div>
			*/
			?>
		</td>
	</tr>
</table>
<div id="map_box" style="position:absolute; width:650px; height:470px; background:#000000; display:none;" align="center">
	<span style="float:right; color:#fff; padding:10px; font-weight:bold; cursor:pointer;" onclick="$('#map_box').hide();">x</span><br />
	<div id="map_canvas" style="width: 600px; height: 400px"></div>
</div>